package manage;

import manage.book.BookList;
import manage.users.AdminUser;
import manage.users.NormalUser;
import manage.users.User;

import java.util.Scanner;

public class Main {

    public static User login(){//通过返回值向上转型达到返回地一致性
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入你的姓名：");
        String name = scan.nextLine();
        System.out.println("请输入你的身份：1->管理员 0->普通用户");
        int choice = scan.nextInt();
        if(choice == 1){
            AdminUser adminUser = new AdminUser(name);
            return adminUser;
        }else {
            NormalUser normalUser = new NormalUser(name);
            return normalUser;
        }
    }
    public static void main(String[] args) {
        BookList bookList = new BookList();
        User user = login();
        while(true) {
            int choice = user.menu();
            //此时可以知道对象的身份和进行的操作

            user.doOperation(choice, bookList);
        }
    }
}